
import { _decorator, Component, Node, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Wall')
export class Wall extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;

    start() {
        // [3]
        this.init(0.5 + 0.5 * Math.random(), (Math.random() > 0.5 ? 1 : -1) * (Math.random() * 0.5));
    }

    // 跳板初始化
    init(width: number, y_Offset: number = 0) {
        // 设置缩放值。用来设置跳板的长度
        let scale = this.node.getScale()
        this.node.setScale(width, scale.y, scale.z)

        // console.log(width, y_Offset)

        // 设置坐标。用来设置跳板的高度
        let pos = this.node.getPosition()
        this.node.setPosition(pos.x, y_Offset, pos.z)

        // console.log(this.node.getPosition())
    }
    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html
 */
